#include <iostream>
#include <pthread.h>
#include "Task.hpp"
#include "ThreadPool.hpp"
#include "thread.hpp"
#include <ctime>
#include <cstdlib>
using namespace std;


void test1()
{
    srand(time(nullptr));
    for (int i = 0; i < 10; i++)
    {
        int len = opers.size();
        int x = rand() % 20;
        int y = rand() % 20;
        char oper = opers[rand() % len];
        Task t(x, y, oper);
        ThreadPool<Task>::getInstance()->PushTask(t);
        cout << t.getTask() << endl;
    }
    ThreadPool<Task>::getInstance()->run();
    sleep(5);//应该是5秒推出的
    ThreadPool<Task>::getInstance()->delInstance();
}

void threadTestFun()
{
    cout << "this is thread!" << endl;
}

// 封装线程的测试
void test2()
{
    thread t(threadTestFun);
    t.run();
    cout << t.name() << endl;
    cout << t.start_time() << endl;
    cout << t.thread_state() << endl;
}

int main()
{
    test1();
    return 0;
}